package com.jindy.module.AssetCheck.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.AssetCheck.domain.AssetCheck;
import com.jindy.module.AssetCheck.service.IAssetCheckService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 资产盘点Controller
 *
 * @author jindy
 * @date 2023-04-27
 */
@RestController
@RequestMapping("/module/AssetCheck")
public class AssetCheckController extends BaseController
{
    @Autowired
    private IAssetCheckService assetCheckService;

    /**
     * 查询资产盘点列表
     */
    @PreAuthorize("@ss.hasPermi('module:AssetCheck:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssetCheck assetCheck)
    {
        startPage();
        List<AssetCheck> list = assetCheckService.selectAssetCheckList(assetCheck);
        return getDataTable(list);
    }

    /**
     * 导出资产盘点列表
     */
    @PreAuthorize("@ss.hasPermi('module:AssetCheck:export')")
    @Log(title = "资产盘点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssetCheck assetCheck)
    {
        List<AssetCheck> list = assetCheckService.selectAssetCheckList(assetCheck);
        ExcelUtil<AssetCheck> util = new ExcelUtil<AssetCheck>(AssetCheck.class);
        util.exportExcel(response, list, "资产盘点数据");
    }

    /**
     * 获取资产盘点详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:AssetCheck:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(assetCheckService.selectAssetCheckById(id));
    }

    /**
     * 新增资产盘点
     */
    @PreAuthorize("@ss.hasPermi('module:AssetCheck:add')")
    @Log(title = "资产盘点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssetCheck assetCheck)
    {
        return toAjax(assetCheckService.insertAssetCheck(assetCheck));
    }

    /**
     * 修改资产盘点
     */
    @PreAuthorize("@ss.hasPermi('module:AssetCheck:edit')")
    @Log(title = "资产盘点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssetCheck assetCheck)
    {
        return toAjax(assetCheckService.updateAssetCheck(assetCheck));
    }

    /**
     * 删除资产盘点
     */
    @PreAuthorize("@ss.hasPermi('module:AssetCheck:remove')")
    @Log(title = "资产盘点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assetCheckService.deleteAssetCheckByIds(ids));
    }
}
